package com.zd.kids.ui.view;

import android.content.Context;
import android.provider.Telephony;
import android.widget.EditText;

import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.blankj.utilcode.util.Utils;
import com.hyy.libray.common.BaseUtils;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.core.CenterPopupView;
import com.zd.kids.DataBean.CommonStatusDataBean;
import com.zd.kids.R;
import com.zd.kids.net.CustomObserver;
import com.zd.kids.net.HttpMethod;

import java.util.HashMap;
import java.util.Map;

import androidx.annotation.NonNull;

/**
 * @ClassName: com.zd.kids.ui.view
 * @Description:
 * @Author: hyy
 * @Date: 2020/6/19
 * @Time: 10:21 AM
 */
public class SendEmailPopupWindow extends CenterPopupView {
    public SendEmailPopupWindow(@NonNull Context context, ConfirmCallBack confirmCallBack) {
        super(context);
        this.confirmCallBack = confirmCallBack;
    }

    EditText ed_email;

    @Override
    protected void init() {
        super.init();

        ed_email = findViewById(R.id.ed_email);

        findViewById(R.id.tv_cancel).setOnClickListener(view -> dismiss());

        findViewById(R.id.tv_confirm).setOnClickListener(view -> {
            KeyboardUtils.hideSoftInput(view);
            String email = ed_email.getText().toString();
            if (!BaseUtils.isEmail(email)) {
                ToastUtils.showShort(StringUtils.getString(R.string.input_correct_email));
            } else {
                confirmCallBack.confrimCallBack(email);
            }

        });

    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.layout_send_email;
    }


    public void showView() {
        new XPopup.Builder(getContext())
                .dismissOnTouchOutside(false)
                .asCustom(this)
                .show();
    }

    private ConfirmCallBack confirmCallBack;

    public interface ConfirmCallBack {
        void confrimCallBack(String email);
    }
}
